﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Class_KetNoi
{
   public class KetNoi_BangLuong:KetNoiCoSoDuLieu
    {
        public void them_BangLuong(string @Thang,string @Nam ,string @MaNV ,string @MaPB,string @LuongCB ,string  @SoNgayTangCa,string  @LuongTangCa ,string @TienBaoHiem ,string @ThucLanh)
        {
            SqlCommand cmd = new SqlCommand("dbo.insert_BangLuong", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@Thang",Convert.ToInt32( Thang));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@Nam",Convert.ToInt32( Nam));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaNV", Convert.ToInt32(MaNV));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaPB", Convert.ToInt32( MaPB));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@LuongCB",Convert.ToDouble( LuongCB));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoNgayTangCa",Convert.ToDouble(SoNgayTangCa));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@LuongTangCa", Convert.ToDouble(LuongTangCa));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@TienBaoHiem", Convert.ToDouble(TienBaoHiem));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@ThucLanh", Convert.ToDouble(ThucLanh));
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
        }
        public void sua_BangLuong(string  @MaLuong,string  @Thang, string @Nam, string  @MaNV,string @MaPB, string @LuongCB, string  @SoNgayTangCa, string  @LuongTangCa, string  @TienBaoHiem, string @ThucLanh)
        {
            SqlCommand cmd = new SqlCommand("dbo.update_BangLuong", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaLuong",MaLuong);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@Thang", Convert.ToInt32(Thang));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@Nam", Convert.ToInt32(Nam));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaNV", Convert.ToInt32(MaNV));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaPB", Convert.ToInt32(MaPB));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@LuongCB",  Convert.ToDouble(LuongCB));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoNgayTangCa",  Convert.ToDouble(SoNgayTangCa));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@LuongTangCa",  Convert.ToDouble(LuongTangCa));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@TienBaoHiem",  Convert.ToDouble(TienBaoHiem));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@ThucLanh",  Convert.ToDouble(ThucLanh));
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
        }
        public void xoa_BangLuong(string @MaLuong)
        {
            SqlCommand cmd = new SqlCommand("dbo.delete_BangLuong", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaLuong",MaLuong);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
        }
        public DataTable Load_BangLuong()
        {
            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand("Load_tbl_BangLuong",cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }
        //public DataTable Load_TraCuuLuongNhanVien()
        //{
        //    //DataTable dt = new DataTable();
        //    //SqlCommand cmd = new SqlCommand("Load_TraCuuLuongNhanVien",cnn);
        //    //cmd.CommandType = CommandType.StoredProcedure;
        //    //SqlDataAdapter da = new SqlDataAdapter(cmd);
        //    //da.Fill(dt);
        //    //return dt;

        //}
        public DataTable TraCuu_LuongNhanVien(string @Thang, string @Nam, string @MaNV)
        {
            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand("TraCuu_LuongNhanVien",cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Thang",Thang);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            cmd.Parameters.AddWithValue("@Nam", Nam);
            da = new SqlDataAdapter(cmd);
            cmd.Parameters.AddWithValue("@MaNV",MaNV);
            da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }
    }

}
